package com.smart.seven.aop.advice.introductioninterceptor;

/**
 * 记录性能监视信息类
 *
 * @author junrui.wang
 * @create 2018/7/24
 */
public class MethodPerformance {
    private long begin;
    private long end;
    private String serviceMethod;

    public MethodPerformance(String serviceMethod) {
        this.serviceMethod = serviceMethod;
        //记录目标类开始执行点时间
        this.begin = System.currentTimeMillis();
    }

    public void printPerformance(){
        //获取目标类执行完成后的系统时间，进而计算出目标类执行时间
        this.end = System.currentTimeMillis();
        long elapse = end - begin;
        //报告目标类执行时间
        System.out.println(serviceMethod + "花费了" + elapse + "毫秒");
    }
}
